package com.sg.gara.viewmodel;

import java.util.List;

import org.apache.log4j.Logger;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.select.annotation.VariableResolver;
import org.zkoss.zk.ui.select.annotation.WireVariable;

import com.sg.gara.entity.WebTestTable;
import com.sg.gara.services.WebTestTableService;

@VariableResolver(org.zkoss.zkplus.spring.DelegatingVariableResolver.class)
public class WebTestTableVM {

	protected static Logger logger = Logger.getLogger("WebTest === ");

	
		
	@WireVariable
	WebTestTableService webTestTableService;
	
	@Init
	public void init() {
		logger.debug("init");
		this.name = "Initiated Name";
		this.value = "Initiated Value";
		this.item = webTestTableService.get(1);
		
		this.list = webTestTableService.list();
	} 

	@NotifyChange({ "name","value" })
	@Command
	public void newOrder() {
		
		this.name = "Modified Name";
		this.value = "Modified Value";
	}
	
	@NotifyChange({ "list" })
	@Command({"new" , "save"})
	public void ns() {
	
		this.list = webTestTableService.list();
		logger.debug("Liast SIZE IS : " + list.size());
	}	
	
	private String name;
	
	private String value;

	private WebTestTable item;
	
	private List<WebTestTable> list;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public WebTestTable getItem() {
		return item;
	}

	public void setItem(WebTestTable item) {
		this.item = item;
	}

	public List<WebTestTable> getList() {
		return list;
	}

	public void setList(List<WebTestTable> list) {
		this.list = list;
	}
  
	
	
}
